<?php

namespace App\Admin\Actions\Grid\Row\SwtMachine;

use Dcat\Admin\Grid\RowAction;
use Dcat\Admin\Widgets\Modal;
use App\Admin\Views\SwtMachine\DheMachineGoodsView;

class MachineGoods extends RowAction
{
    protected $title = '库存';
    public function render()
    {
        $source_type = $this->row->source_type;

        $id = $this->getKey();



        switch ($source_type) {
            case 0 :
            break;
            case 1 :
                $button = <<<HTML
            <a><i class="feather icon-eye text-success"></i> <span class="text-success">{$this -> title}</span> &emsp;</a>
        HTML;
                $title = $this->title . ' - '. $this->row->machine_no;

                $body = new DheMachineGoodsView(['id' => $id]);

                return Modal::make()
                    ->xl()
                    ->scrollable()
                    ->title($title)
                    ->body($body)
                    ->button($button);
            break;
            case 2 :
                $button = <<<HTML
            <a href="swt_machine_good?machine_id={$id}"><i class="feather icon-eye text-success"></i> <span class="text-success">{$this -> title}</span> &emsp;</a>
        HTML;
                return $button;
            break;
        }

    }
}
